You can declare JavaScript variables with the var statement:
	var x=5;
	var carname="Volvo";


-----------------------


Assigning Values to Undeclared JavaScript Variables:
If you assign values to variables that have not yet been declared, the variables will automatically be declared.

x=5;
carname="Volvo";

have the same effect as:

var x=5;
var carname="Volvo";

----------------------------

Here we can have the java redeclaration also, For eg.
	
	t1, t2=8;
	var t1 = t2 = 9;	
	alert(t1 +' / '+t2);

----------------------------

var t1 = t2 = t3;	
document.writeln(t1);

/// produces script error, saying t3 is undefined

-------------------------------------

What are undefined and undeclared variables? 

Undeclared variables are those that are not declared in the program (do not exist at all),trying to read their values gives runtime error.But if undeclared variables are assigned then implicit declaration is done . 
Undefined variables are those that are not assigned any value but are declared in the program.Trying to read such variables gives special value called undefined value. 



--------------------------------

	total = 1+2+"3"+9+9;
	alert(total);

--------------------------------

Data Types are : 
	1) String
	2) Boolean 
	3) Number
	4) null, undefined


--------------------------------

Data Type Conversion
	JavaScript is a loosely typed language. That means you do not have to specify the data type of a variable when you declare it, and data types are converted automatically as needed during script execution. So, for example, you could define a variable as follows:

	var answer = 42 

	And later, you could assign the same variable a string value, for example, 

	answer = "Thanks for all the fish..." 



====================================================================================

1) var s1 = new String("www")
	is as same same 
	var s1 = String("www"); 
	this holds same thing for all other data types


String conversion

var newNumber = 34.56;
var newBoolean = true;
var nothing;
var newNull = null;

var strNumber = String(newNumber); 
var strBoolean = String(newBoolean);
var strUndefined = String(nothing); 
var strNull = String(newNull);

var strOutput = "<p>" + strNumber + " " + strBoolean + " " + strUndefined + " "+ strNull + "</p>";
document.writeln(strOutput);

var strOutput2 = String(document);
document.writeln(strOutput2);

--------------------------------------------

Boolean conversion


Note:: Boolean(unfilled string or null or undefined or unassigned) --> false
var s1 = ""; // Boolean(strOne) -- false
var s2 = null; // Boolean(strZero) -- false
var s3 = undefined; // Boolean(strNumber) -- false
var s4; // Boolean(strNumber) -- false

Note:: Boolean(filled string) --> true
var strOne = "1"; // Boolean(strOne) -- true
var strZero = "0"; // Boolean(strZero) -- true
var strNumber = "99.22"; // Boolean(strNumber) -- true
var strFloatNumber = "99.22"; // Boolean(strFloatNumber) -- true


Note:: other than zero, conversion to boolean will be true
var zero = 0; // Boolean(zero) -- false
var one = 1; // Boolean(one) -- true
var s2 = 22; // Boolean(s2) -- true
var s1 = -23; // Boolean(s1) -- true
var s3 = 2E-12; // Boolean(s3) -- true

------------------------------------------------------------

Number conversion

Note:: 1) converts string to number that has the value from negitive to positve(also can be floating and decimal points) proper numerical integer
	   2) string that contains "2e3" will convert to proper number (ie. 2000)

var n1 = "-1212"; //Number(n1) --> -1212
var n2 = "0"; //Number(n1) --> 0
var n3 = "23"; //Number(n1) --> 23
var n4 = "2e3"; // floating number  //Number(n1) --> 2000
var n5 = "2123.233";// floating number //Number(n1) --> 2123.233
var n6 = "123 23";//Number(n1) --> NaN
var n7 = "sjdhg";//Number(n1) --> NaN
var n8 = "true";//Number(n1) --> NaN


<script type="text/javascript">

document.write(parseInt("10") + "<br />");
document.write(parseInt("10.33") + "<br />");
document.write(parseInt("34 45 66") + "<br />");
document.write(parseInt(" 60 ") + "<br />");
document.write(parseInt("40 years") + "<br />");
document.write(parseInt("He was 40") + "<br />");

document.write("<br />");
document.write(parseInt("10",10)+ "<br />");
document.write(parseInt("010")+ "<br />");
document.write(parseInt("10",8)+ "<br />");
document.write(parseInt("0x10")+ "<br />");
document.write(parseInt("10",16)+ "<br />");

document.write("<BR>" + parseInt("15"))
document.write("<BR>" + parseInt("12.12345"))
document.write("<BR>" + parseInt("45.00000000"))
document.write("<BR>" + parseInt("23.348  44.218  55.405"))
document.write("<BR>" + parseInt("    55 aardvarks"))
document.write("<BR>" + parseInt("Year 2002"))

parseInt(" 0xF", 16);
parseInt(" F", 16);
parseInt("17", 8);
parseInt(021, 8);
parseInt("015", 10);
parseInt(15.99, 10);
parseInt("FXX123", 16);
parseInt("1111", 2);
parseInt("15*3", 10);
parseInt("15e2", 10);
parseInt("15px", 10);
parseInt("12", 13);

parseInt("Hello", 8); // Not a number at all
parseInt("546", 2);   // Digits are not valid for binary representations

parseInt("-F", 16);
parseInt("-0F", 16);
parseInt("-0XF", 16);
parseInt(-10, 16);
parseInt(-15.1, 10)
parseInt(" -17", 8);
parseInt(" -15", 10);
parseInt("-1111", 2);
parseInt("-15e1", 10);
parseInt("-12", 13);

</script>



--------------------------------------------------------------------------------------------------------------------------------------------
parseFloat
var n1 = "-1212"; //parseFloat(n1) --> -1212
var n2 = "0"; //parseFloat(n1) --> 0
var n3 = "23"; //parseFloat(n1) --> 23
var n4 = "2e3"; // floating number  //parseFloat(n1) --> 2000
var n5 = "2123.233";// floating number //parseFloat(n1) --> 2123.233
var n6 = "123 23";//parseFloat(n1) --> NaN
var n7 = "sjdhg";//parseFloat(n1) --> NaN
var n8 = "true";//parseFloat(n1) --> NaN


var strOutput = "<p>" +parseFloat(n1) + " " +parseFloat(n2) + " " +parseFloat(n3) + " " +parseFloat(n4) + " " +parseFloat(n5) + " " +parseFloat(n6) + " " +parseFloat(n7) + " " +parseFloat(n8) + " " + "</p>";
document.writeln(strOutput);



---------------------------------------------------------------------------
parseInt
var n1 = "-1212"; //parseInt(n1) --> -1212
var n2 = "0"; //parseInt(n1) --> 0
var n3 = "23"; //parseInt(n1) --> 23
var n4 = "2e3"; // floating number  //parseInt(n1) --> 2000
var n5 = "2123.233";// floating number //parseInt(n1) --> 2123.233
var n6 = "123 23";//parseInt(n1) --> NaN
var n7 = "sjdhg";//parseInt(n1) --> NaN
var n8 = "true";//parseInt(n1) --> NaN


var strOutput = "<p>" +parseInt(n1) + " " +parseInt(n2) + " " +parseInt(n3) + " " +parseInt(n4) + " " +parseInt(n5) + " " +parseInt(n6) + " " +parseInt(n7) + " " +parseInt(n8) + " " + "</p>";
document.writeln(strOutput);




check out pare
